import java.util.Arrays;
import java.util.Locale;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: atp
 * Date: 2022-11-26
 * Time: 20:11
 */
class Student {
    public String name;
    public int age;

    @Override
    public String toString() {
        return "Student{" +
                "name='" + name + '\'' +
                ", age=" + age +
                '}';
    }

    public Student(String name, int age) {
        this.name = name;
        this.age = age;

    }
}
public class Test {
    public static void main(String[] args) {
        String s1="abc"+"def";//1
        String s2=new String(s1);//2
        if(s1.equals(s2))//3
            System.out.println(".equals succeeded");//4
        if(s1==s2)//5
            System.out.println("==succeeded");
    }

    public static boolean isAdmin(String userId){
        return userId.toLowerCase()=="admin";
    }
    public static void main13(String[] args){
        System.out.println(isAdmin("Admin"));
    }


    public static void main12(String[] args) {
        String s1 = " hello hello   ";
        boolean flg = s1.contains("hello");
        System.out.println(flg);

        String s2 = "abcabcdabcdef";
        System.out.println(s2.endsWith("abcd")); //是否以它结尾
        System.out.println(s2.startsWith("abc")); //开始
    }

    public static void main10(String[] args) {
        String s1 = "helloworld";
        String str1 = s1.substring(1,4); //[1,4)
        System.out.println(str1);

        String str2 = " hello hello    ";
        String ret = str2.trim();
        System.out.print(ret);
        System.out.println("bjhjh");
    }


    public static void main9(String[] args) {
        String s = "zs&ww&zl&ls";
        String[] ret = s.split("&",2);
        System.out.println(Arrays.toString(ret));

        String s2 = "13.56.111";
        String[] ret2 = s2.split("\\.");
        for (String x:ret2) {
            System.out.print(x+" ");
        }

        String s3 = "13\\56\\111";
        String[] str3 = s3.split("\\\\");
        for (String x:str3) {
            System.out.print(x+" ");
        }

        System.out.println();
        String s4 = "name=zs&age=18";
        String[] ret4 = s4.split("=|&");
        for (String x: ret4) {
            System.out.println(x);
        }
    }

    public static void main8(String[] args) {
        String s = "ababcabcdabcde";
        String ret = s.replace("ab","jk");
        System.out.println(ret);
    }

    public static void main7(String[] args) {
        String s = "hello";
        String ret = s.toUpperCase();
        System.out.println(ret);

        String s1 ="YUGUIG";
        String ret1 = s1.toLowerCase();
        System.out.println(ret1);

        char[] chars = s1.toCharArray();
        System.out.println(Arrays.toString(chars));
    }


    public static void main6(String[] args) {
        //转字符串
        String s = String.valueOf(5145);
        System.out.println(s);

        String s1 = String.valueOf(true);
        System.out.println(s1);

        String s3 = String.valueOf(new Student("zhangsan",18));
        System.out.println(s3);

        int val1 = Integer.parseInt("123");
        System.out.println(val1+1);
        double val2 = Double.parseDouble("555.23");
        System.out.println(val2+15);
    }

    public static void main4(String[] args) {
        for (int i = 0; i < args.length; i++) {
            System.out.println(args[i]);
        }
    }

    public static void main3(String[] args) {
        String str1 = "abcdecf";
        for (int i = 0; i < str1.length(); i++) {
            char ch = str1.charAt(i);
            System.out.println(ch);
        }
        System.out.println(str1.indexOf('c'));
        System.out.println(str1.indexOf('c',3));
        System.out.println(str1.indexOf("cde"));
        System.out.println(str1.indexOf("cde",3));
        System.out.println(str1.lastIndexOf('c'));
        System.out.println(str1.lastIndexOf('c',3));

    }

    public static void main2(String[] args) {
        String str1 = new String("hello");
        String str2 = new String("world");
        String str3 = new String("World");

        System.out.println(str1.equals(str2));
        System.out.println(str2.equals(str3));

        int n = str2.compareToIgnoreCase(str3);
        System.out.println(n);

    }

    public static void main1(String[] args) {
        String str = new String("但是不记得");
        char[] chars = {'g','b','o'};
        String str2 = new String(chars);
    }
}
